package com.wisdom.admin.service.impl;

import com.wisdom.admin.client.LocationClient;
import com.wisdom.admin.service.PolyLocationService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * 位置服务端接口实现类
 * @author mingc
 * @date 2021-03-25 12:33 下午
 */
@Service
public class PolyLocationServiceImpl implements PolyLocationService {
    private static final Logger LOGGER = LoggerFactory.getLogger(PolyLocationServiceImpl.class);

    @Autowired
    LocationClient locationClient;

    @Override
    public Map getLocation(String longitude, String latitude) {
        Map result = locationClient.getLocation(longitude,latitude);
        if (result == null){
            return null;
        }
        Object status = result.get(new String("status"));
        if (!status.equals("1")){
            LOGGER.warn("接口调用异常:{}",result);
            return null;
        }
        return (Map) result.get(new String("data"));
    }
}
